﻿#ifndef FACADE_H
#define FACADE_H

#include "common/t_facade.h"
#include "searchbox.h"
#include "receiver.h"
#include "popup.h"
#include "note.h"
#include "note2.h"
#include "memo.h"
#include "head/g_function.h"
#include "support/pivx.h"
#include "remind/reminder.h"
#include "remind/remindonce.h"

#define skin_note ui->body->setStyleSheet("image: url(:/res/note.png)")

namespace Ui {
class Facade;
}

class Facade : public TransFacade
{
    Q_OBJECT

public:
    explicit Facade(QWidget *parent = 0);
    ~Facade();

    void keyPressEvent(QKeyEvent *event);
    void mouseDoubleClickEvent(QMouseEvent *);

    void startUp();
    void connectStorage();

    void startReceiver();
    void endReceiver();
    void startReminder();
    void endReminder();

    void receivedMessage(const QString &label,const QString &detail);
    void raisedRemind(const QString &detail);

    void showNote();
    void showNote2();
    void showMemo();
    void detectMemo();
    void showRemind();
    void invokeCalc();
    void showSearchBox();

    void pop(const QString &, const QString &);

    void createMenu();
    void generateMenu();
    void reloadMenu();

    void createOptionMenu();
    void createPropsMenu();

    QString getPart() const;
    void putPart(const QString &part);
    void checkStaff();

    QHash<QString,QString> getPropsDetail() const;

    void processPropsAction(QAction *);
    void processMenuAction(QAction *);

private:
    Ui::Facade *ui;

    QSqlDatabase db;
    QString userLand;
    Popup *popup;
    Note *note;
    Note2 *note2;
    Memo *memo;
    RemindOnce *remindMan;
    SearchBox *searchBox;

    Reminder *reminder;
    QThread remindThread;

    Receiver *receiver;
    QThread recvThread;

    QHash<QString,QString> propsMenuItems;
    QHash<QString,QString> menuItems;
    QList<QMenu *> menuList;
};

#endif // FACADE_H
